CountReservoirs Function

public function CountReservoirs(list) result(c)

count number of reservoirs in a list

Arguments

Type IntentOptional Attributes Name
type(Reservoir), intent(in), POINTER :: list

Return Value integer(kind=short)


Variables

Type Visibility Attributes Name Initial
type(Reservoir), public, POINTER :: p

Source Code

FUNCTION CountReservoirs &
( list) &
RESULT (c)

IMPLICIT NONE 

!Arguments with intent in:
TYPE(Reservoir), POINTER, INTENT(IN) :: list !list of reservoirs

!Arguments with intent out:
INTEGER(KIND = short) :: c

!local arguments:
TYPE(Reservoir), POINTER :: p !pointer to reservoir

!------------end of declaration------------------------------------------------

!loop througout list of reservoirs searching for id
p => list
c = 0
DO WHILE (ASSOCIATED(p)) 
  c = c + 1
  p => p % next
ENDDO

RETURN
END FUNCTION CountReservoirs